#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <iostream>

#define SERVER_IP "0.0.0.0"
#define SERVER_PORT 8080

int main()
{
  int sock = socket(AF_INET, SOCK_STREAM, 0);

  struct sockaddr_in svraddr;
  svraddr.sin_addr.s_addr = inet_addr(SERVER_IP);
  svraddr.sin_family = AF_INET;
  svraddr.sin_port = htons(SERVER_PORT);

  connect(sock, (struct sockaddr*)&svraddr, sizeof svraddr);
  char buffer[] = "hello world";
  while(1)
  {
    send(sock, buffer, sizeof(buffer) - 1, 0);
    std::cout << "send : " << buffer << std::endl;
    sleep(1);
  }

  close(sock);
  return 0;
}
